package com.ruoyi.web.controller.customer;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.customer.domain.OutboundOrder;
import com.ruoyi.customer.domain.OutboundTable;
import com.ruoyi.customer.service.IOutboundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 储存商品Controller
 * 
 * @author 王梦川
 * @date 2024-10-25
 */
@RestController
@RequestMapping("/customer/outbound")
public class OutboundController extends BaseController
{
    @Autowired
    private IOutboundService outboundService;;

    /**
     * 查询储存商品列表
     */
    @PreAuthorize("@ss.hasPermi('customer:outbound:list')")
    @GetMapping("/list")
    public TableDataInfo list(OutboundTable outboundTable)
    {
        startPage();
        System.out.println(outboundTable);
        List<OutboundOrder> list = outboundService.selectOutboundOrderList(outboundTable);
        return getDataTable(list);
    }


    /**
     * 获取储存商品详细信息
     */
    @PreAuthorize("@ss.hasPermi('customer:outbound:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(outboundService.selectOutboundOrderById(id));
    }

    /**
     * 新增储存商品
     */
    @PreAuthorize("@ss.hasPermi('customer:outbound:add')")
    @Log(title = "储存商品", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OutboundTable wareHouseout) {
        System.out.println(wareHouseout);
        return toAjax(outboundService.insertOutboundOrder(wareHouseout));
    }

    /**
     * 修改储存商品
     */
    @PreAuthorize("@ss.hasPermi('customer:outbound:edit')")
    @Log(title = "储存商品", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody List<OutboundOrder> outboundOrderList)
    {
        return toAjax(outboundService.updateOutboundOrder(outboundOrderList));
    }

    /**
     * 删除储存商品
     */
    @PreAuthorize("@ss.hasPermi('customer:outbound:remove')")
    @Log(title = "储存商品", businessType = BusinessType.DELETE)
	@GetMapping("/remove")
    public AjaxResult remove(Long id, String wareoutNo)
    {
        return toAjax(outboundService.deleteOutboundOrderByIds(id,wareoutNo));
    }
}
